<?php
/**
 * 订单模型
 * 
 + ----------------------------------------------------- 
 * Date 2013-3-8
 + -----------------------------------------------------
 */
class OrderModel extends CommonModel {
	
	protected $_validate	=	array(
		array('name','require','请输入姓名！'),
		array('card_number','require','请输入姓名！'),
		array('mobile','require','请输入手机号码！'),
		array('email','email','邮箱号码不正确！'),
	);

	protected $_auto		=	array(
		array('password','pwdHash',1,'callback'),
		array('add_time','time',1,'function'),
	);

	protected function pwdHash() {
		if(isset($_POST['password'])) {
			return md5(trim($_POST['password']));
		}else{
			return false;
		}
	}
	
	//修改信息时密码为空则不修改
	protected function autoPwd(){
		if(empty($_POST['password'])){
			$user=$this->where("id=$_POST[id]")->field('password')->find();
			if($user){
				return $user['password'];
			}
		}else{
			return md5(trim($_POST['password']));
		}
	}
}
?>